package com.atxyj.springsecurity.system.web.request;

import com.atxyj.springsecurity.system.entity.User;
import com.atxyj.springsecurity.system.validator.FullName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

/**
 * @author xieyujiao
 * @description 用户注册请求
 * @date 2021/7/30
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserRegisterRequest {


        @NotBlank
        private String userName;
        @NotBlank
        private String password;
        @FullName
        @NotBlank
        private String fullName;

        public User toUser() {
            return User.builder()
                    .fullName(this.getFullName())
                    .userName(this.getUserName())
                    .enabled(true)
                    .build();
        }
}
